package com.shensi.appCollect.controller;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.shensi.appCollect.pojo.OilPriceInfo;
import com.shensi.appCollect.service.OilPriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
@RequestMapping("/oilPrice")
@CrossOrigin
@Api(tags = "油价信息")
public class OilController {

    @Resource
    private OilPriceService oilPriceService;

    @ApiOperation(value = "查询油站价格")
    @GetMapping("/getOilPrice")
    @ResponseBody
    public String getOilPrice(@RequestParam String stationId){
        OilPriceInfo oilPrice = oilPriceService.getOilPrice(stationId);
        Gson gson = new GsonBuilder().serializeNulls().create();
        return gson.toJson(oilPrice);

    }


}
